package com.ht.controller;

import com.ht.data.Result;
import com.ht.domain.bo.TbDoctorBO;
import com.ht.domain.po.TbDoctor;
import com.ht.domain.vo.TbDoctorVO;
import com.ht.dto.TbDiagnoseOrderDTO;
import com.ht.feign.ExpertOutpatientFeign;
import com.ht.service.TbDoctorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController  //等于@Restquest + @Controller
@RequestMapping("/physicalInterpretation")
@Api("体检快速解读管理系统")
@RefreshScope  //实时刷新
public class PhysicalInterpretationController {
    @Autowired
    private TbDoctorService tbDoctorService;

    @Autowired
    private ExpertOutpatientFeign expertOutpatientFeign;

    @PostMapping("/queryDoctorPhysical")
    @ApiOperation("查看所有支持体检解读的医生")
    @ApiImplicitParam()
    public Result queryDoctorPhysical(){
        List<TbDoctorBO> list = tbDoctorService.queryDoctorPhysical(3);
        List<TbDoctorVO> listt = new ArrayList<>();
        list.forEach(obj->{
            TbDoctorVO vo = new TbDoctorVO();
            BeanUtils.copyProperties(obj,vo);
            listt.add(vo);
        });
        return Result.OK().setData(listt);
    }

    @PostMapping("/queryDoctorCost")
    @ApiOperation("选定医生缴费")
    @ApiImplicitParam()
    public Result queryDoctor(TbDiagnoseOrderDTO dto){
        Result result = expertOutpatientFeign.outpatientRegistered(dto);
        return result;
    }
}
